package com.lagou.emailservice;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @author zhangxuyuan
 * @version 1.0
 * @date 2021/1/15
 */
@Service
public class EmailSend {

    @Autowired
    private JavaMailSender sender;
    @Async
    public void send(String email,String code)
    {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom("1559761282@qq.com");
        message.setTo(email);
        message.setSubject("这是验证码");
        message.setText(code);
        sender.send(message);
    }
}
